﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Enterprise.Data.Article;
using Enterprise.Model.Article;
namespace Enterprise.Service.Article
{
    /// <summary>
    /// 通过公告签收服务
    /// </summary>
    public class ArticleRecevieService
    {
        /// <summary>
        /// 判断签收人是否签收通知公告
        /// </summary>
        /// <param name="articleId">通过公告编号</param>
        /// <param name="userId">用户编号</param>
        /// <returns></returns>
        public bool ArticleRecevieCheck(int articleId, int userId)
        {
            ArticleRecevieData data = new ArticleRecevieData();
            return data.ArticleRecevieCheck(articleId, userId);
        }

        /// <summary>
        ///  通知公告签收数据列表
        /// </summary>
        /// <returns></returns>
        public List<ArticleRecevieEntity> ArticleRecevieList(int articleId)
        {
            ArticleRecevieData data = new ArticleRecevieData();
            return data.ArticleRecevieList(articleId);
        }

        /// <summary>
        /// 通知公告 添加、修改、删除
        /// </summary>
        /// <param name="entity">组织机构实体</param>
        public void ArticleRecevieExecute(ArticleRecevieEntity entity)
        {
            string cmd = string.Empty;
            switch (entity.DB_Option_Action)
            {
                case "Insert":
                    cmd = "Insert into ARTICLE_RECEVIE(RECEVIEID,INFOID,RUSERID,RDATETIME) values(SEQ_ARTICLE_RECEVIE.nextval," + entity.InfoId + "," + entity.RUserId + ",to_date('" + entity.RDateTime + "','YYYY-MM-DD HH24:MI:SS'))";
                    break;                
            }
            if (!string.IsNullOrEmpty(cmd))
            {
                ArticleRecevieExecuteBySql(cmd);
            }
        }

        /// <summary>
        /// 通知公告签收人操作  
        /// </summary>
        /// <param name="cmd">sql语句</param>
        public void ArticleRecevieExecuteBySql(string cmd)
        {
            ArticleRecevieData data = new ArticleRecevieData();
            data.ArticleRecevieExecute(cmd);
        }

    }
}
